package com.yuyou.tas.lesson.api;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.yuyou.tas.lesson.service.IBaseLevelService;
import com.yuyou.tas.lesson.service.IBaseSchoolService;
import com.yuyou.tas.lesson.service.IBaseSectionService;
import com.yuyou.tas.lesson.service.IBaseService;
import com.yuyou.tas.lesson.service.IBaseTermService;
import com.yuyou.tas.lesson.service.ILessonClassService;
import com.yuyou.tas.lesson.service.IStudentService;
import com.yuyou.tas.service.api.lesson.entity.BaseLevel;
import com.yuyou.tas.service.api.lesson.entity.BaseSchool;
import com.yuyou.tas.service.api.lesson.entity.BaseSection;
import com.yuyou.tas.service.api.lesson.entity.BaseTrimester;
import com.yuyou.tas.service.api.lesson.entity.Student;
import com.yuyou.tas.service.api.lesson.service.BaseDataAPI;
import com.yuyou.tas.service.api.lesson.vo.LessonClassVo;
import com.yuyou.tas.util.bean.ResBoolSimpleInfo;
import com.yuyou.tas.util.enums.lesson.LessonBaseEnums;

@RestController
public class BaseDataAPIImpl implements BaseDataAPI{

	@Autowired
	private IBaseService service;

	@Autowired
	IBaseSchoolService baseSchoolService;

	@Autowired
	IBaseSectionService baseSectionService;
	
	@Autowired
	IBaseTermService baseTermService;

	@Autowired
	ILessonClassService lessonClassService;

	@Autowired
	IStudentService studentService;

	@Autowired
	IBaseLevelService baseLevelService;

	@Override
	public boolean copyBaseService(@RequestParam(value = "userID") Long userID  ,@RequestParam(value = "userOrganId") Long userOrganId, @RequestParam(value = "organId")Long organId) {
		return service.copyBaseData(userID ,userOrganId, organId);
	}

	@Override
	public ResBoolSimpleInfo<String> syncSchool(@RequestBody List<BaseSchool> baseSchool ) {
		return baseSchoolService.syncSchool(baseSchool);
	}

	@Override
	public ResBoolSimpleInfo<String> delSchoolByOrgan7OIds(@RequestParam("oIds") List<Long> oIds,@RequestParam("authOrganizationId") Long authOrganizationId) throws Exception {
		return baseSchoolService.delSchoolByOrgan7OIds(oIds, authOrganizationId);
	}

	@Override
	public BaseSection selectBaseSectionById(Long id) {
		return baseSectionService.selectBaseSectionById(id);
	}

	@Override
	public List<BaseSection> findBaseSectionByIds(@RequestParam("ids") List<Long> ids) {
		return baseSectionService.findBaseSectionByIds(ids);
	}

	@Override
	public List<BaseSection> findSectionName(Map<String, Object> condition) {
		condition.put("isUse", LessonBaseEnums.isEnableed.enabl.getValue());
		condition.put("isStan", 1);//获取标准数据
		List<BaseSection> sectionName = baseSectionService.findSectionName(condition);
		return sectionName;
	}

	@Override
	public ResBoolSimpleInfo<String> syncTrimester(
			@RequestBody List<BaseTrimester> list) {
		return baseTermService.syncTrimester(list);
	}

	@Override
	public ResBoolSimpleInfo<String> delTrimesterByOrgan7OIds(@RequestParam("oIds")List<Long> oIds,
			@RequestParam("authOrganizationId") Long authOrganizationId) throws Exception {
		return baseTermService.delTrimesterByOrgan7OIds(oIds, authOrganizationId);
	}

	@Override
	public List<BaseTrimester> findTrimByOran(@RequestParam("authOrganizationId") Long authOrganizationId) {
		return baseTermService.findTrimByOran(authOrganizationId);
	}

	@Override
	public List<BaseSchool> getSchoolByOrganId(Long organId) {
		return baseSchoolService.getByOrganId(organId);
	}

	@Override
	public List<LessonClassVo> findLessonClassByOrganId(Long organId) {
		return lessonClassService.findLessonClassByOrganId(organId);
	}

	@Override
	public List<Student> selectStudentByOrganId(Long organId) {
		return studentService.selectByOrganId(organId);
	}

	@Override
	public Student selectStudentByOrganIdStuNo(Long organId, String stuNo) {
		return studentService.selectStudentByOrganIdStuNo(organId , stuNo);
	}

	@Override
	public List<BaseLevel> findBaseLevelByOrganId(Long organId) {

		return baseLevelService.findBaseLevelByOrganId(organId);
	}

	@Override
	public List<BaseSection> findBaseSection() {
		return baseSectionService.findAllBaseSection();
	}

}
